package xcmg.device.web.sale;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import xcmg.device.infra.BasicController;
import xcmg.device.infra.ErrorCode;
import xcmg.device.service.sale.SaleIntentionDeleteReasonService;
import xcmg.device.service.vo.sale.SaleIntentionDeleteReasonVO;
import yb.ecp.fast.infra.annotation.FastMappingInfo;
import yb.ecp.fast.infra.infra.ActionResult;
import yb.ecp.fast.infra.infra.PageCommonVO;
import yb.ecp.fast.infra.infra.SearchCommonVO;

/**
 * Created by 阿斯顿 on 2018/8/15.
 */
@RequestMapping("/saleIntentionDeleteReason")
@RestController
public class SaleIntentionDeleteReasonController  extends BasicController {

    @Autowired
    private SaleIntentionDeleteReasonService saleIntentionDeleteReasonService;

    @RequestMapping(value = "/list",method = RequestMethod.POST)
    @FastMappingInfo(needLogin = true)
    public ActionResult list(@RequestBody SearchCommonVO<SaleIntentionDeleteReasonVO> condition)throws Exception{
        if(condition==null){
            return actionResult(ErrorCode.IllegalArument);
        }
        if(condition.getFilters()==null){
            SaleIntentionDeleteReasonVO saleIntentionDeleteReasonVO=new SaleIntentionDeleteReasonVO();
            saleIntentionDeleteReasonVO.setOrgId(getOrgId());
            condition.setFilters(saleIntentionDeleteReasonVO);
        }
        else {
            condition.getFilters().setOrgId(getOrgId());
        }
        PageCommonVO pageCommonVO=saleIntentionDeleteReasonService.list(condition);
        return actionValueResult(pageCommonVO.getPageInfo());
    }

}
